package com.king.designpatterns.结构型模式.组合模式;

import java.util.ArrayList;

/**
 * 树枝节点
 *
 * @author king
 * @date 2021-06-08 13:46
 */
public class ConcreteCompany implements Company{
    private ArrayList<Company> companies = new ArrayList<>();
    /**
     * 姓名
     */
    private String name;
    /**
     * 职位
     */
    private String position;
    /**
     * 薪水
     */
    private int salary;

    public ConcreteCompany(String name, String position, int salary) {
        this.name = name;
        this.position = position;
        this.salary = salary;
    }

    public void add(Company company){
        this.companies.add(company);
    }

    public void remove(Company company) {
        this.companies.remove(company);
    }

    public ArrayList<Company> getChild(){
        return this.companies;
    }

    @Override
    public String getInfo(){
        String info = "名称：" + this.name + "\t职位：" + this.position + "\t薪水" + this.salary;
        return info;
    }
}
